package enumdemo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-09-19
 * Time: 20:23
 */
public class Singleton {
    /*静态内部类实现
    private Singleton() {

    }
    public static Singleton getSingleton() {
        return UserSingletonHolder.STR;
    }
    //静态内部类
    private static class UserSingletonHolder {
        private static final Singleton STR = new Singleton();
    }*/

    /*懒汉式
    private static Singleton singleton;
    private Singleton() {

    }
    public Singleton getSingleton() {
        if(singleton == null) {
            singleton = new Singleton();
        }
        return singleton;
    }*/

    /*饿汉式
    private static Singleton singleton = new Singleton();
    private Singleton() {

    }
    public Singleton getSingleton() {
        return singleton;
    }*/
}
